define(function () {
    return function ($compile, $scope) {
        require(["PDUtilDir/util", "AppPathDir/finance/groupFinanceInfos/support", "AppPathDir/finance/groupFinanceInfos/visitor", "AppPathDir/finance/groupFinanceInfos/detail", "PDUtilDir/inputSelect",
            "Date", "DateCN", "css!DateCss"], function (Util, Support, VisitorSupport, DetailSupport, inputSelect) {
            /* 查询 start */
            $scope.search = {};
            $scope.cache = {
                status: new Array(),
                statusMap: new Map(),
                oper_data: [{
                    dictName: "小于",
                    dictCode: "<"
                }, {
                    dictName: "大于",
                    dictCode: ">"
                }, {
                    dictName: "等于",
                    dictCode: "=="
                }]
            };
            $scope.searchSupport = {
                run: function () {
                    $scope.grid.reload({
                        queryParam: {
                            model: JSON.stringify($scope.search)
                        }
                    })
                }
            };
            $scope.visitorSupport = VisitorSupport($scope, $compile);
            $scope.detailSupport = DetailSupport($scope, $compile);

            //获取团状态
            $.ajax({
                url: getServer() + "/flea/hclv/getTravelGroupStatus.htmls",
                success: function (data) {
                    $scope.cache.status = data.data;

                    $.each(data.data, function (index, row) {
                        $scope.cache.statusMap.set(row.dictCode, row.dictName);
                    });

                    // 初始化状态下拉框
                    inputSelect.dropCache();
                    inputSelect({
                        id: "groupStatus",
                        key: {
                            id: "dictCode",
                            name: "dictName",
                            data: "data",
                        },
                        data: $scope.cache.status,
                        simpleData: true,
                        searchAble: false,
                        callback: function (id) {
                            $scope.search.groupStatus = id[0];
                        }
                    });
                    $scope.grid = Support.init($scope.cache, $scope.searchSupport);
                }
            });
            // 初始化班期
            $("#time_table").datetimepicker({
                // 设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
                language: "cn",
                // 输出格式化
                format: 'yyyy-mm-dd',
                // 直接选择‘今天’
                todayBtn: true,
                // 设置最精确的时间选择视图
                minView: 'month',
                // 高亮当天日期
                todayHighlight: true,
                // 选择完毕后自动关闭
                autoclose: true
            });

            inputSelect.dropCache();
            inputSelect({
                id: "oper1",
                key: {
                    id: "dictCode",
                    name: "dictName",
                    data: "data"
                },
                data: $scope.cache.oper_data,
                simpleData: true,
                searchAble: false,
                callback: function (id) {
                    $scope.search.oper1 = id[0];
                }
            });

            inputSelect.dropCache();
            inputSelect({
                id: "oper2",
                key: {
                    id: "dictCode",
                    name: "dictName",
                    data: "data"
                },
                data: $scope.cache.oper_data,
                simpleData: true,
                searchAble: false,
                callback: function (id) {
                    $scope.search.oper2 = id[0];
                }
            });
        })
    }
});